import React, {useContext} from 'react';
import WFC from '../context/OperatorContext';
import {RightOutlined} from '@ant-design/icons';
import NodeWrap from './Wrap';
import TitleElement from './TitleElement';

const getOwner = (userList = []) => {
  return userList.map((user) => user.label).join('、');
};
function StartNode(props) {
  const {onSelectNode, handleOpenStartDrawer} = useContext(WFC);
  const delNode = (e) => {
    e.stopPropagation();
    // onDeleteNode(props.pRef, props.objRef, 0);
  };
  function onContentClick() {
    onSelectNode(props.pRef, props.objRef);
    handleOpenStartDrawer();
  }
  let TitleEl = <TitleElement delNode={delNode} nodeName={props.nodeName} />;
  return (
    <NodeWrap type={0} objRef={props.objRef} onContentClick={onContentClick} title={TitleEl}>
      <div className='text' title={props.nodeUserList?.length > 0 && getOwner(props.nodeUserList)}>
        {props.nodeUserList?.length > 0 && getOwner(props.nodeUserList)}
      </div>
      <RightOutlined />
    </NodeWrap>
  );
}
export default StartNode;
